1//////////////////////////////////////////////////////////////////////
2// LibFile: threading.scad
3// Triangular and Trapezoidal-Threaded Screw Rods and Nuts.
4// To use, add the following lines to the beginning of your file:
5// ```
6// include <BOSL/constants.scad>
7// use <BOSL/threading.scad>
8// ```
9//////////////////////////////////////////////////////////////////////
10
11/*
12BSD 2-Clause License
13
14Copyright (c) 2017-2019, Revar Desmera
15All rights reserved.
16
17Redistribution and use in source and binary forms, with or without
18modification, are permitted provided that the following conditions are met:
19
20* Redistributions of source code must retain the above copyright notice, this
21 list of conditions and the following disclaimer.
22
23* Redistributions in binary form must reproduce the above copyright notice,
24 this list of conditions and the following disclaimer in the documentation
25 and/or other materials provided with the distribution.
26
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37*/
38
39include <constants.scad>
40use <transforms.scad>
41use <masks.scad>
42use <math.scad>
43
44
45// Section: Generic Trapezoidal Threading
46
47// Module: trapezoidal_threaded_rod()
48// Description:
49// Constructs a generic trapezoidal threaded screw rod. This method makes
50// much smoother threads than the naive linear_extrude method.
51// For metric trapezoidal threads, use thread_angle=15 and thread_depth=pitch/2.
52// For ACME threads, use thread_angle=14.5 and thread_depth=pitch/2.
53// For square threads, use thread_angle=0 and thread_depth=pitch/2.
54// For normal UTS or ISO screw threads, use the `threaded_rod()` module instead to get the correct thread profile.
55// Arguments:
56// d = Outer diameter of threaded rod.
57// l = Length of threaded rod.
58// pitch = Length between threads.
59// thread_depth = Depth of the threads. Default=pitch/2
60// thread_angle = The pressure angle profile angle of the threads. Default = 14.5 degree ACME profile.
61// left_handed = If true, create left-handed threads. Default = false
62// bevel = if true, bevel the thread ends. Default: false
63// bevel1 = if true, bevel the axis-negative end of the thread. Default: false
64// bevel2 = if true, bevel the axis-positive end of the thread. Default: false
65// starts = The number of lead starts. Default = 1
66// internal = If true, make this a mask for making internal threads.
67// slop = printer slop calibration to allow for tight fitting of parts. Default: `PRINTER_SLOP`
68// profile = The shape of a thread, if not a symmetric trapezoidal form. Given as a 2D path, where X is between -1/2 and 1/2, representing the pitch distance, and Y is 0 for the peak, and `-depth/pitch` for the valleys. The segment between the end of one thread profile and the start of the next is automatic, so the start and end coordinates should not both be at the same Y at X = ±1/2. This path is scaled up by the pitch size in both dimensions when making the final threading. This overrides the `thread_angle` and `thread_depth` options.
69// orient = Orientation of the rod. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
70// align = Alignment of the rod. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
71// center = If given, overrides `align`. A true value sets `align=V_CENTER`, false sets `align=ALIGN_POS`.
72// Examples(Med):
73// trapezoidal_threaded_rod(d=10, l=40, pitch=2, thread_angle=15, $fn=32);
74// trapezoidal_threaded_rod(d=3/8*25.4, l=20, pitch=1/8*25.4, thread_angle=29, $fn=32);
75// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=45, left_handed=true, $fa=2, $fs=2);
76// trapezoidal_threaded_rod(d=60, l=16, pitch=8, thread_depth=3, thread_angle=45, left_handed=true, starts=4, $fa=2, $fs=2);
77// trapezoidal_threaded_rod(d=16, l=40, pitch=2, thread_angle=30);
78// trapezoidal_threaded_rod(d=10, l=40, pitch=3, thread_angle=15, left_handed=true, starts=3, $fn=36);
79// trapezoidal_threaded_rod(d=25, l=40, pitch=10, thread_depth=8/3, thread_angle=50, starts=4, center=false, $fa=2, $fs=2);
80// trapezoidal_threaded_rod(d=50, l=35, pitch=8, thread_angle=30, starts=3, bevel=true);
81// trapezoidal_threaded_rod(l=25, d=10, pitch=2, thread_angle=15, starts=3, $fa=1, $fs=1, orient=ORIENT_X, align=V_UP);
82module trapezoidal_threaded_rod(
83 d=10,
84 l=100,
85 pitch=2,
86 thread_angle=15,
87 thread_depth=undef,
88 left_handed=false,
89 bevel=false,
90 bevel1=false,
91 bevel2=false,
92 starts=1,
93 profile=undef,
94 internal=false,
95 slop=undef,
96 orient=ORIENT_Z,
97 align=V_CENTER,
98 center=undef
99) {
100 function _thread_pt(thread, threads, start, starts, astep, asteps, part, parts) =
101 astep + asteps * (thread + threads * (part + parts * start));
102
103 d = internal? d+default(slop,PRINTER_SLOP)*3 : d;
104 astep = 360 / quantup(segs(d/2), starts);
105 asteps = ceil(360/astep);
106 threads = ceil(l/pitch/starts)+(starts<4?4-starts:1);
107 depth = min((thread_depth==undef? pitch/2 : thread_depth), pitch/2/tan(thread_angle));
108 pa_delta = min(pitch/4-0.01,depth*tan(thread_angle)/2)/pitch;
109 dir = left_handed? -1 : 1;
110 r1 = -depth/pitch;
111 z1 = 1/4-pa_delta;
112 z2 = 1/4+pa_delta;
113 profile = profile!=undef? profile : [
114 [-z2, r1],
115 [-z1, 0],
116 [ z1, 0],
117 [ z2, r1],
118 ];
119 parts = len(profile);
120 poly_points = concat(
121 [
122 for (
123 start = [0 : starts-1],
124 part = [0 : parts-1],
125 thread = [0 : threads-1],
126 astep = [0 : asteps-1]
127 ) let (
128 ppt = profile[part] * pitch,
129 dz = ppt.x,
130 r = ppt.y + d/2,
131 a = astep / asteps,
132 c = cos(360 * (a * dir + start/starts)),
133 s = sin(360 * (a * dir + start/starts)),
134 z = (thread + a - threads/2) * starts * pitch
135 ) [r*c, r*s, z+dz]
136 ],
137 [[0, 0, -threads*pitch*starts/2-pitch/4], [0, 0, threads*pitch*starts/2+pitch/4]]
138 );
139 point_count = len(poly_points);
140 poly_faces = concat(
141 // Thread surfaces
142 [
143 for (
144 start = [0 : starts-1],
145 part = [0 : parts-2],
146 thread = [0 : threads-1],
147 astep = [0 : asteps-1],
148 trinum = [0, 1]
149 ) let (
150 p0 = _thread_pt(thread, threads, start, starts, astep, asteps, part, parts),
151 p1 = _thread_pt(thread, threads, start, starts, astep, asteps, part+1, parts),
152 p2 = _thread_pt(thread, threads, start, starts, astep+1, asteps, part, parts),
153 p3 = _thread_pt(thread, threads, start, starts, astep+1, asteps, part+1, parts),
154 tri = trinum==0? [p0, p1, p3] : [p0, p3, p2],
155 otri = left_handed? [tri[0], tri[2], tri[1]] : tri
156 )
157 if (!(thread == threads-1 && astep == asteps-1)) otri
158 ],
159 // Thread trough bottom
160 [
161 for (
162 start = [0 : starts-1],
163 thread = [0 : threads-1],
164 astep = [0 : asteps-1],
165 trinum = [0, 1]
166 ) let (
167 p0 = _thread_pt(thread, threads, start, starts, astep, asteps, parts-1, parts),
168 p1 = _thread_pt(thread, threads, (start+(left_handed?1:starts-1))%starts, starts, astep+asteps/starts, asteps, 0, parts),
169 p2 = p0 + 1,
170 p3 = p1 + 1,
171 tri = trinum==0? [p0, p1, p3] : [p0, p3, p2],
172 otri = left_handed? [tri[0], tri[2], tri[1]] : tri
173 )
174 if (
175 !(thread >= threads-1 && astep > asteps-asteps/starts-2) &&
176 !(thread >= threads-2 && starts == 1 && astep >= asteps-1)
177 ) otri
178 ],
179 // top and bottom thread endcap
180 [
181 for (
182 start = [0 : starts-1],
183 part = [1 : parts-2],
184 is_top = [0, 1]
185 ) let (
186 astep = is_top? asteps-1 : 0,
187 thread = is_top? threads-1 : 0,
188 p0 = _thread_pt(thread, threads, start, starts, astep, asteps, 0, parts),
189 p1 = _thread_pt(thread, threads, start, starts, astep, asteps, part, parts),
190 p2 = _thread_pt(thread, threads, start, starts, astep, asteps, part+1, parts),
191 tri = is_top? [p0, p1, p2] : [p0, p2, p1],
192 otri = left_handed? [tri[0], tri[2], tri[1]] : tri
193 ) otri
194 ],
195 // body side triangles
196 [
197 for (
198 start = [0 : starts-1],
199 is_top = [false, true],
200 trinum = [0, 1]
201 ) let (
202 astep = is_top? asteps-1 : 0,
203 thread = is_top? threads-1 : 0,
204 ostart = (is_top != left_handed? (start+1) : (start+starts-1))%starts,
205 ostep = is_top? astep-asteps/starts : astep+asteps/starts,
206 oparts = is_top? parts-1 : 0,
207 p0 = is_top? point_count-1 : point_count-2,
208 p1 = _thread_pt(thread, threads, start, starts, astep, asteps, 0, parts),
209 p2 = _thread_pt(thread, threads, start, starts, astep, asteps, parts-1, parts),
210 p3 = _thread_pt(thread, threads, ostart, starts, ostep, asteps, oparts, parts),
211 tri = trinum==0?
212 (is_top? [p0, p1, p2] : [p0, p2, p1]) :
213 (is_top? [p0, p3, p1] : [p0, p3, p2]),
214 otri = left_handed? [tri[0], tri[2], tri[1]] : tri
215 ) otri
216 ],
217 // Caps
218 [
219 for (
220 start = [0 : starts-1],
221 astep = [0 : asteps/starts-1],
222 is_top = [0, 1]
223 ) let (
224 thread = is_top? threads-1 : 0,
225 part = is_top? parts-1 : 0,
226 ostep = is_top? asteps-astep-2 : astep,
227 p0 = is_top? point_count-1 : point_count-2,
228 p1 = _thread_pt(thread, threads, start, starts, ostep, asteps, part, parts),
229 p2 = _thread_pt(thread, threads, start, starts, ostep+1, asteps, part, parts),
230 tri = is_top? [p0, p2, p1] : [p0, p1, p2],
231 otri = left_handed? [tri[0], tri[2], tri[1]] : tri
232 ) otri
233 ]
234 );
235 orient_and_align([d,d,l], orient, align, center) {
236 difference() {
237 polyhedron(points=poly_points, faces=poly_faces, convexity=threads*starts*2);
238 zspread(l+4*pitch*starts) cube([d+1, d+1, 4*pitch*starts], center=true);
239 if (bevel || bevel1 || bevel2) {
240 depth1 = (bevel || bevel1) ? depth : 0;
241 depth2 = (bevel || bevel2) ? depth : 0;
242 cylinder_mask(d=d, l=l+0.01, chamfer1=depth1, chamfer2=depth2);
243 }
244 }
245 }
246}
247
248
249// Module: trapezoidal_threaded_nut()
250// Description:
251// Constructs a hex nut for a threaded screw rod. This method makes
252// much smoother threads than the naive linear_extrude method.
253// For metric screw threads, use thread_angle=30 and leave out thread_depth argument.
254// For SAE screw threads, use thread_angle=30 and leave out thread_depth argument.
255// For metric trapezoidal threads, use thread_angle=15 and thread_depth=pitch/2.
256// For ACME threads, use thread_angle=14.5 and thread_depth=pitch/2.
257// For square threads, use thread_angle=0 and thread_depth=pitch/2.
258// Arguments:
259// od = diameter of the nut.
260// id = diameter of threaded rod to screw onto.
261// h = height/thickness of nut.
262// pitch = Length between threads.
263// thread_depth = Depth of the threads. Default=pitch/2.
264// thread_angle = The pressure angle profile angle of the threads. Default = 14.5 degree ACME profile.
265// left_handed = if true, create left-handed threads. Default = false
266// starts = The number of lead starts. Default = 1
267// bevel = if true, bevel the thread ends. Default: true
268// slop = printer slop calibration to allow for tight fitting of parts. Default: `PRINTER_SLOP`
269// profile = The shape of a thread, if not a symmetric trapezoidal form. Given as a 2D path, where X is between -1/2 and 1/2, representing the pitch distance, and Y is 0 for the peak, and `-depth/pitch` for the valleys. The segment between the end of one thread profile and the start of the next is automatic, so the start and end coordinates should not both be at the same Y at X = ±1/2. This path is scaled up by the pitch size in both dimensions when making the final threading. This overrides the `thread_angle` and `thread_depth` options.
270// orient = Orientation of the nut. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
271// align = Alignment of the nut. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
272// Examples(Med):
273// trapezoidal_threaded_nut(od=16, id=8, h=8, pitch=2, slop=0.2, align=V_UP);
274// trapezoidal_threaded_nut(od=17.4, id=10, h=10, pitch=2, slop=0.2, left_handed=true);
275// trapezoidal_threaded_nut(od=17.4, id=10, h=10, pitch=2, thread_angle=15, starts=3, $fa=1, $fs=1);
276module trapezoidal_threaded_nut(
277 od=17.4,
278 id=10,
279 h=10,
280 pitch=2,
281 thread_depth=undef,
282 thread_angle=15,
283 profile=undef,
284 left_handed=false,
285 starts=1,
286 bevel=true,
287 slop=undef,
288 orient=ORIENT_Z,
289 align=V_CENTER
290) {
291 depth = min((thread_depth==undef? pitch/2 : thread_depth), pitch/2/tan(thread_angle));
292 slop = default(slop, PRINTER_SLOP);
293 orient_and_align([od/cos(30),od,h], orient, align) {
294 difference() {
295 cylinder(d=od/cos(30), h=h, center=true, $fn=6);
296 trapezoidal_threaded_rod(
297 d=id,
298 l=h+1,
299 pitch=pitch,
300 thread_depth=depth,
301 thread_angle=thread_angle,
302 profile=profile,
303 left_handed=left_handed,
304 starts=starts,
305 internal=true,
306 slop=slop
307 );
308 if (bevel) {
309 zflip_copy() {
310 down(h/2+0.01) {
311 cylinder(r1=id/2+slop, r2=id/2+slop-depth, h=depth, center=false);
312 }
313 }
314 }
315 }
316 }
317}
318
319
320// Section: Triangular Threading
321
322// Module: threaded_rod()
323// Description:
324// Constructs a standard metric or UTS threaded screw rod. This method
325// makes much smoother threads than the naive linear_extrude method.
326// Arguments:
327// d = Outer diameter of threaded rod.
328// l = length of threaded rod.
329// pitch = Length between threads.
330// left_handed = if true, create left-handed threads. Default = false
331// bevel = if true, bevel the thread ends. Default: false
332// bevel1 = if true, bevel the axis-negative end of the thread. Default: false
333// bevel2 = if true, bevel the axis-positive end of the thread. Default: false
334// internal = If true, make this a mask for making internal threads.
335// slop = printer slop calibration to allow for tight fitting of parts. Default: `PRINTER_SLOP`
336// orient = Orientation of the rod. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
337// align = Alignment of the rod. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
338// Example(2D):
339// projection(cut=true)
340// threaded_rod(d=10, l=15, pitch=2, orient=ORIENT_X);
341// Examples(Med):
342// threaded_rod(d=10, l=20, pitch=1.25, left_handed=true, $fa=1, $fs=1);
343// threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1);
344module threaded_rod(
345 d=10, l=100, pitch=2,
346 left_handed=false,
347 bevel=false,
348 bevel1=false,
349 bevel2=false,
350 internal=false,
351 slop=undef,
352 orient=ORIENT_Z,
353 align=V_CENTER
354) {
355 depth = pitch * cos(30) * 5/8;
356 profile = internal? [
357 [-6/16, -depth/pitch],
358 [-1/16, 0],
359 [-1/32, 0.02],
360 [ 1/32, 0.02],
361 [ 1/16, 0],
362 [ 6/16, -depth/pitch]
363 ] : [
364 [-7/16, -depth/pitch*1.07],
365 [-6/16, -depth/pitch],
366 [-1/16, 0],
367 [ 1/16, 0],
368 [ 6/16, -depth/pitch],
369 [ 7/16, -depth/pitch*1.07]
370 ];
371 trapezoidal_threaded_rod(
372 d=d, l=l, pitch=pitch,
373 thread_depth=depth,
374 thread_angle=30,
375 profile=profile,
376 left_handed=left_handed,
377 bevel=bevel,
378 bevel1=bevel1,
379 bevel2=bevel2,
380 internal=internal,
381 slop=slop,
382 orient=orient,
383 align=align
384 );
385}
386
387
388
389// Module: threaded_nut()
390// Description:
391// Constructs a hex nut for a metric or UTS threaded screw rod. This method
392// makes much smoother threads than the naive linear_extrude method.
393// Arguments:
394// od = diameter of the nut.
395// id = diameter of threaded rod to screw onto.
396// h = height/thickness of nut.
397// pitch = Length between threads.
398// left_handed = if true, create left-handed threads. Default = false
399// bevel = if true, bevel the thread ends. Default: false
400// slop = printer slop calibration to allow for tight fitting of parts. default=0.2
401// orient = Orientation of the nut. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
402// align = Alignment of the nut. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
403// Examples(Med):
404// threaded_nut(od=16, id=8, h=8, pitch=1.25, left_handed=true, slop=0.2, $fa=1, $fs=1);
405module threaded_nut(
406 od=16, id=10, h=10,
407 pitch=2, left_handed=false,
408 bevel=false, slop=undef,
409 orient=ORIENT_Z, align=V_CENTER
410) {
411 depth = pitch * cos(30) * 5/8;
412 profile = [
413 [-6/16, -depth/pitch],
414 [-1/16, 0],
415 [-1/32, 0.02],
416 [ 1/32, 0.02],
417 [ 1/16, 0],
418 [ 6/16, -depth/pitch]
419 ];
420 trapezoidal_threaded_nut(
421 od=od, id=id, h=h,
422 pitch=pitch, thread_angle=30,
423 profile=profile,
424 left_handed=left_handed,
425 bevel=bevel, slop=slop,
426 orient=orient, align=align
427 );
428}
429
430
431// Section: Buttress Threading
432
433// Module: buttress_threaded_rod()
434// Description:
435// Constructs a simple buttress threaded screw rod. This method
436// makes much smoother threads than the naive linear_extrude method.
437// Arguments:
438// d = Outer diameter of threaded rod.
439// l = length of threaded rod.
440// pitch = Length between threads.
441// left_handed = if true, create left-handed threads. Default = false
442// bevel = if true, bevel the thread ends. Default: false
443// bevel1 = if true, bevel the axis-negative end of the thread. Default: false
444// bevel2 = if true, bevel the axis-positive end of the thread. Default: false
445// internal = If true, this is a mask for making internal threads.
446// slop = printer slop calibration to allow for tight fitting of parts. default=0.2
447// orient = Orientation of the rod. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
448// align = Alignment of the rod. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
449// Example(2D):
450// projection(cut=true)
451// buttress_threaded_rod(d=10, l=15, pitch=2, orient=ORIENT_X);
452// Examples(Med):
453// buttress_threaded_rod(d=10, l=20, pitch=1.25, left_handed=true, $fa=1, $fs=1);
454// buttress_threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1);
455module buttress_threaded_rod(
456 d=10, l=100, pitch=2,
457 left_handed=false,
458 bevel=false,
459 bevel1=false,
460 bevel2=false,
461 internal=false,
462 slop=undef,
463 orient=ORIENT_Z,
464 align=V_CENTER
465) {
466 depth = pitch * 3/4;
467 profile = [
468 [ -7/16, -0.75],
469 [ 5/16, 0],
470 [ 7/16, 0],
471 [ 7/16, -0.75],
472 [ 1/ 2, -0.77],
473 ];
474 trapezoidal_threaded_rod(
475 d=d, l=l, pitch=pitch,
476 thread_depth=depth,
477 thread_angle=30,
478 profile=profile,
479 left_handed=left_handed,
480 bevel=bevel,
481 bevel1=bevel1,
482 bevel2=bevel2,
483 internal=internal,
484 orient=orient,
485 slop=slop,
486 align=align
487 );
488}
489
490
491
492// Module: buttress_threaded_nut()
493// Description:
494// Constructs a hex nut for a simple buttress threaded screw rod. This method
495// makes much smoother threads than the naive linear_extrude method.
496// Arguments:
497// od = diameter of the nut.
498// id = diameter of threaded rod to screw onto.
499// h = height/thickness of nut.
500// pitch = Length between threads.
501// left_handed = if true, create left-handed threads. Default = false
502// bevel = if true, bevel the thread ends. Default: false
503// slop = printer slop calibration to allow for tight fitting of parts. default=0.2
504// orient = Orientation of the nut. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
505// align = Alignment of the nit. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
506// Examples:
507// buttress_threaded_nut(od=16, id=8, h=8, pitch=1.25, left_handed=true, slop=0.2, $fa=1, $fs=1);
508module buttress_threaded_nut(
509 od=16, id=10, h=10,
510 pitch=2, left_handed=false,
511 bevel=false, slop=undef,
512 orient=ORIENT_Z, align=V_CENTER
513) {
514 depth = pitch * 3/4;
515 profile = [
516 [ -7/16, -0.75],
517 [ 5/16, 0],
518 [ 7/16, 0],
519 [ 7/16, -0.75],
520 [ 1/ 2, -0.77],
521 ];
522 trapezoidal_threaded_nut(
523 od=od, id=id, h=h,
524 pitch=pitch, thread_angle=30,
525 profile=profile,
526 thread_depth=pitch*3*sqrt(3)/8,
527 left_handed=left_handed,
528 bevel=bevel, slop=slop,
529 orient=orient, align=align
530 );
531}
532
533
534// Section: Metric Trapezoidal Threading
535
536// Module: metric_trapezoidal_threaded_rod()
537// Description:
538// Constructs a metric trapezoidal threaded screw rod. This method makes much
539// smoother threads than the naive linear_extrude method.
540// Arguments:
541// d = Outer diameter of threaded rod.
542// l = length of threaded rod.
543// pitch = Length between threads.
544// left_handed = if true, create left-handed threads. Default = false
545// bevel = if true, bevel the thread ends. Default: false
546// starts = The number of lead starts. Default = 1
547// orient = Orientation of the rod. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
548// align = Alignment of the rod. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
549// Example(2D):
550// projection(cut=true)
551// metric_trapezoidal_threaded_rod(d=10, l=15, pitch=2, orient=ORIENT_X);
552// Examples(Med):
553// metric_trapezoidal_threaded_rod(d=10, l=30, pitch=2, left_handed=true, $fa=1, $fs=1);
554module metric_trapezoidal_threaded_rod(
555 d=10, l=100, pitch=2,
556 left_handed=false,
557 starts=1,
558 bevel=false,
559 bevel1=false,
560 bevel2=false,
561 orient=ORIENT_Z,
562 align=V_CENTER
563) {
564 trapezoidal_threaded_rod(
565 d=d, l=l,
566 pitch=pitch,
567 thread_angle=15,
568 left_handed=left_handed,
569 starts=starts,
570 bevel=bevel,
571 bevel1=bevel1,
572 bevel2=bevel2,
573 orient=orient,
574 align=align
575 );
576}
577
578
579
580// Module: metric_trapezoidal_threaded_nut()
581// Description:
582// Constructs a hex nut for a metric trapezoidal threaded screw rod. This method
583// makes much smoother threads than the naive linear_extrude method.
584// Arguments:
585// od = diameter of the nut.
586// id = diameter of threaded rod to screw onto.
587// h = height/thickness of nut.
588// pitch = Length between threads.
589// left_handed = if true, create left-handed threads. Default = false
590// bevel = if true, bevel the thread ends. Default: false
591// starts = The number of lead starts. Default = 1
592// slop = printer slop calibration to allow for tight fitting of parts. default=0.2
593// orient = Orientation of the nut. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
594// align = Alignment of the nut. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
595// Examples(Med):
596// metric_trapezoidal_threaded_nut(od=16, id=10, h=10, pitch=2, left_handed=true, bevel=true, $fa=1, $fs=1);
597module metric_trapezoidal_threaded_nut(
598 od=17.4, id=10.5, h=10,
599 pitch=3.175,
600 starts=1,
601 left_handed=false,
602 bevel=false,
603 slop=undef,
604 orient=ORIENT_Z,
605 align=V_CENTER
606) {
607 trapezoidal_threaded_nut(
608 od=od, id=id, h=h,
609 pitch=pitch, thread_angle=15,
610 left_handed=left_handed,
611 starts=starts,
612 bevel=bevel,
613 slop=slop,
614 orient=orient,
615 align=align
616 );
617}
618
619
620// Section: ACME Trapezoidal Threading
621
622// Module: acme_threaded_rod()
623// Description:
624// Constructs an ACME trapezoidal threaded screw rod. This method makes
625// much smoother threads than the naive linear_extrude method.
626// Arguments:
627// d = Outer diameter of threaded rod.
628// l = length of threaded rod.
629// pitch = Length between threads.
630// thread_depth = Depth of the threads. Default = pitch/2
631// thread_angle = The pressure angle profile angle of the threads. Default = 14.5 degrees
632// starts = The number of lead starts. Default = 1
633// left_handed = if true, create left-handed threads. Default = false
634// bevel = if true, bevel the thread ends. Default: false
635// bevel1 = if true, bevel the axis-negative end of the thread. Default: false
636// bevel2 = if true, bevel the axis-positive end of the thread. Default: false
637// orient = Orientation of the rod. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
638// align = Alignment of the rod. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
639// Example(2D):
640// projection(cut=true)
641// acme_threaded_rod(d=10, l=15, pitch=2, orient=ORIENT_X);
642// Examples(Med):
643// acme_threaded_rod(d=3/8*25.4, l=20, pitch=1/8*25.4, $fn=32);
644// acme_threaded_rod(d=10, l=30, pitch=2, starts=3, $fa=1, $fs=1);
645module acme_threaded_rod(
646 d=10, l=100, pitch=2,
647 thread_angle=14.5,
648 thread_depth=undef,
649 starts=1,
650 left_handed=false,
651 bevel=false,
652 bevel1=false,
653 bevel2=false,
654 orient=ORIENT_Z,
655 align=V_CENTER
656) {
657 trapezoidal_threaded_rod(
658 d=d, l=l, pitch=pitch,
659 thread_angle=thread_angle,
660 thread_depth=thread_depth,
661 starts=starts,
662 left_handed=left_handed,
663 bevel=bevel,
664 bevel1=bevel1,
665 bevel2=bevel2,
666 orient=orient,
667 align=align
668 );
669}
670
671
672
673// Module: acme_threaded_nut()
674// Description:
675// Constructs a hex nut for an ACME threaded screw rod. This method makes
676// much smoother threads than the naive linear_extrude method.
677// Arguments:
678// od = diameter of the nut.
679// id = diameter of threaded rod to screw onto.
680// h = height/thickness of nut.
681// pitch = Length between threads.
682// thread_depth = Depth of the threads. Default=pitch/2
683// thread_angle = The pressure angle profile angle of the threads. Default = 14.5 degree ACME profile.
684// left_handed = if true, create left-handed threads. Default = false
685// bevel = if true, bevel the thread ends. Default: false
686// slop = printer slop calibration to allow for tight fitting of parts. default=0.2
687// orient = Orientation of the nut. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
688// align = Alignment of the nut. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
689// Examples(Med):
690// acme_threaded_nut(od=16, id=3/8*25.4, h=8, pitch=1/8*25.4, slop=0.2);
691// acme_threaded_nut(od=16, id=10, h=10, pitch=2, starts=3, slop=0.2, $fa=1, $fs=1);
692module acme_threaded_nut(
693 od, id, h, pitch,
694 thread_angle=14.5,
695 thread_depth=undef,
696 starts=1,
697 left_handed=false,
698 bevel=false,
699 slop=undef,
700 orient=ORIENT_Z,
701 align=V_CENTER
702) {
703 trapezoidal_threaded_nut(
704 od=od, id=id, h=h, pitch=pitch,
705 thread_depth=thread_depth,
706 thread_angle=thread_angle,
707 left_handed=left_handed,
708 bevel=bevel,
709 starts=starts,
710 slop=slop,
711 orient=orient,
712 align=align
713 );
714}
715
716
717// Section: Square Threading
718
719// Module: square_threaded_rod()
720// Description:
721// Constructs a square profile threaded screw rod. This method makes
722// much smoother threads than the naive linear_extrude method.
723// Arguments:
724// d = Outer diameter of threaded rod.
725// l = length of threaded rod.
726// pitch = Length between threads.
727// left_handed = if true, create left-handed threads. Default = false
728// bevel = if true, bevel the thread ends. Default: false
729// bevel1 = if true, bevel the axis-negative end of the thread. Default: false
730// bevel2 = if true, bevel the axis-positive end of the thread. Default: false
731// starts = The number of lead starts. Default = 1
732// orient = Orientation of the rod. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
733// align = Alignment of the rod. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
734// Example(2D):
735// projection(cut=true)
736// square_threaded_rod(d=10, l=15, pitch=2, orient=ORIENT_X);
737// Examples(Med):
738// square_threaded_rod(d=10, l=20, pitch=2, starts=2, $fn=32);
739module square_threaded_rod(
740 d=10, l=100, pitch=2,
741 left_handed=false,
742 bevel=false,
743 bevel1=false,
744 bevel2=false,
745 starts=1,
746 orient=ORIENT_Z,
747 align=V_CENTER
748) {
749 trapezoidal_threaded_rod(
750 d=d, l=l, pitch=pitch,
751 thread_angle=0,
752 left_handed=left_handed,
753 bevel=bevel,
754 bevel1=bevel1,
755 bevel2=bevel2,
756 starts=starts,
757 orient=orient,
758 align=align
759 );
760}
761
762
763
764// Module: square_threaded_nut()
765// Description:
766// Constructs a hex nut for a square profile threaded screw rod. This method
767// makes much smoother threads than the naive linear_extrude method.
768// Arguments:
769// od = diameter of the nut.
770// id = diameter of threaded rod to screw onto.
771// h = height/thickness of nut.
772// pitch = Length between threads.
773// left_handed = if true, create left-handed threads. Default = false
774// bevel = if true, bevel the thread ends. Default: false
775// bevel1 = if true, bevel the axis-negative end of the thread. Default: false
776// bevel2 = if true, bevel the axis-positive end of the thread. Default: false
777// starts = The number of lead starts. Default = 1
778// slop = printer slop calibration to allow for tight fitting of parts. default=0.2
779// orient = Orientation of the nut. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
780// align = Alignment of the nut. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
781// Examples(Med):
782// square_threaded_nut(od=16, id=10, h=10, pitch=2, starts=2, slop=0.15, $fn=32);
783module square_threaded_nut(
784 od=17.4, id=10.5, h=10,
785 pitch=3.175,
786 left_handed=false,
787 bevel=false,
788 bevel1=false,
789 bevel2=false,
790 starts=1,
791 slop=undef,
792 orient=ORIENT_Z,
793 align=V_CENTER
794) {
795 trapezoidal_threaded_nut(
796 od=od, id=id, h=h, pitch=pitch,
797 thread_angle=0,
798 left_handed=left_handed,
799 bevel=bevel,
800 bevel1=bevel1,
801 bevel2=bevel2,
802 starts=starts,
803 slop=slop,
804 orient=orient,
805 align=align
806 );
807}
808
809
810
811// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap